﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RRRSRoguelike.Helpers
{
    public struct DungeonSquare 
    {
        public string character;
        public ConsoleColor color;
    }

    public class Layer
    {
        //for drawing dungeon
        public DungeonSquare[,] DungeonSquares;

        //for preventing redrawing
        public DungeonSquare[,] OldDungeonSquares;

        public Layer()
        {
            DungeonSquares = new DungeonSquare[Constants.DungeonWidth, Constants.DungeonHeight];

            OldDungeonSquares = new DungeonSquare[Constants.DungeonWidth, Constants.DungeonHeight];

        }

        public Layer(int width, int height)
        {
            DungeonSquares = new DungeonSquare[width, height];

            OldDungeonSquares = new DungeonSquare[width, height];

        }

        public bool HasChanged(int x,int y) 
        {
            if(this.DungeonSquares[x,y].character != this.OldDungeonSquares[x,y].character ||
                this.DungeonSquares[x, y].color != this.OldDungeonSquares[x, y].color)
                    return true;

            return false;
        }

        public void ClearOldSquares()
        {
            OldDungeonSquares = new DungeonSquare[Constants.DungeonWidth,Constants.DungeonHeight];
        }

        public void RecordOldSquares()
        {
            OldDungeonSquares = (DungeonSquare[,])DungeonSquares.Clone();
        }




    }
}
